﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Lister;
using COFE.Core;
using COFE.Core.Profile;
using COFE.Core.Entry;

namespace COFE.Data.Profile
{
    public interface IDBEntryManager
    {
        /// <summary>
        /// Lookup a dbEntry using it's id and return it.
        /// </summary>
        /// <param name="context">Database to run on.</param>
        /// <param name="profile">Return null if the profile does not authorized to use that entries.</param>
        /// <param name="entryId"></param>
        /// <returns></returns>
        Entry LookupEntry(COFEDB2 context, IUserProfile profile, Guid entryId);

        /// <summary>
        /// Lookup a dbEntry using it's fullParseName (with primary volume id) and return it.
        /// </summary>
        /// <param name="context">Database to run on.</param>
        /// <param name="profile">Return null if the profile does not authorized to use that entries.</param>
        /// <param name="fullParseName"></param>
        /// <returns></returns>
        Entry LookupEntry(COFEDB2 context, IUserProfile profile, string fullParseName);        

        /// <summary>
        /// Remove a dbEntry from database.
        /// </summary>
        /// <param name="entryGuid"></param>
        void RemoveEntry(Guid entryGuid);

        /// <summary>
        /// Render a database cache to expired if exists. (RefreshTime = COFEDBShared.DTMin)
        /// </summary>
        /// <param name="entryGuid"></param>
        void ExpireEntry(Guid entryGuid, bool isEntryChanged, bool isListingChanged);

        /// <summary>
        /// Create or Update a group of entries in database.
        /// </summary>
        /// <param name="entryPPs">Original Primary property providers, Must not be DBCachePropertyProvider.</param>
        /// <param name="hasSameParent">All entryPPs has the same parent directory.</param>
        /// <param name="isFullListing">Whether it's full el of their parent directory</param>
        void UpdateEntry(COFEDB2 context, IEnumerable<IPropertyProvider> entryPPs, bool hasSameParent, bool isFullListing);

        
        /// <summary>
        /// Create or Update an dbEntry in database.
        /// </summary>
        /// <param name="entryPP">Original primary property provider.</param>
        /// <param name="isThreaded">Whether update the database in thread pool.</param>        
        /// <returns>If not isThreaded, return the database dbEntry.</returns>
        Entry UpdateEntry(COFEDB2 context, IPropertyProvider entryPP);        

        /// <summary>
        /// Notify the database that the specified directory is empty.
        /// </summary>
        /// <param name="directory">The directory's primary property provider.</param>
        void UpdateDirectoryIsEmpty(COFEDB2 context, IPropertyProvider dirPP);
    }


    
}
